Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Language Guide / Part 2 - AppleScript Language Reference
Chapter 7 - Control Statements / Repeat Statements


Repeat (number) Times

The Repeat (number) Times form of the Repeat statement repeats a group of statements a specified number of times.

SYNTAX
repeat integer [ times ]
   [ statement ]...
end [ repeat ]
where

integer is an integer that specifies the number of times to repeat the statements in the body of the loop. The word times after integer is optional.

statement is any AppleScript statement.

EXAMPLE
The following example numbers the paragraphs of a document with the Repeat (number) Times form of the Repeat statement.

tell document "List"   set numParagraphs to (count paragraphs)
   set paragraphNum to 1
   repeat numParagraphs times
      set paragraph paragraphNum to (paragraphNum as string) & " " ÿ         & paragraph paragraphNum
      set paragraphNum to paragraphNum + 1
   end repeat
end tell

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996